package com.qingyun.system.service.impl;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.qingyun.system.common.result.PageResult;
import com.qingyun.system.common.result.Result;
import com.qingyun.system.model.entity.Company;
import com.qingyun.system.model.query.CompanyPageQuery;
import com.qingyun.system.model.query.CompanyQuery;
import com.qingyun.system.model.vo.CompanyVO;
import com.qingyun.system.model.vo.PageVO;
import com.qingyun.system.service.CompanyService;
import com.qingyun.system.mapper.CompanyMapper;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.List;

/**
* @author Administrator
* @description 针对表【biz_company(公司信息表)】的数据库操作Service实现
* @createDate 2024-12-10 14:16:52
*/
@Service
@Slf4j
public class CompanyServiceImpl extends ServiceImpl<CompanyMapper, Company>
    implements CompanyService{

    @Resource
    private CompanyMapper companyMapper;


    /**
     * 根据条件分页查询公司列表
     *
     * @param queryParam
     * @return
     */
    @Override
    public PageVO<CompanyVO> search(CompanyPageQuery queryParam) {
        Page<Company> page = this.lambdaQuery()
                .like(StrUtil.isNotBlank(queryParam.getName()), Company::getName, queryParam.getName())
                .like(StrUtil.isNotBlank(queryParam.getPhone()), Company::getMobile, queryParam.getPhone())
                .eq(queryParam.getStatus() != null, Company::getStatus, queryParam.getStatus())
                .page(queryParam.toMpPage("create_time", false));
        PageVO<CompanyVO> companyVOPageVO = PageVO.of(page, CompanyVO.class);
        return companyVOPageVO;
    }


}




